package com.cskaoyan.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class DateUtils {

    public static Date getCurrentDate(String dateFormat){

        return new Date();
    }

    public static Date transferDate(String data){
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parse = null;
        try {
            parse = dateFormat.parse(data);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return parse;
    }

    public static String getOrderSn(){
        Random random = new Random();
        String temp = "";
        for (int i = 0; i < 6; i++) {
            temp = temp + random.nextInt(10);
        }
        DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
        String result = dateFormat.format(new Date()) + temp;
        return result;
    }
}
